package game;

import java.awt.Point;

import game.GameDice.DiceColour;
import game.GameDice.DiceType;
import view.swing.SwingView;

public class GamePlay {
	
	private SwingView sw;
	private BoardState bs;
	private GameReferee gf;
	private boolean end;
	private boolean isRedsTurn;
	
	public GamePlay() {
		this.bs  = new BoardState();
		this.sw  = new SwingView();
		this.setGf(new GameReferee(bs));
		this.setEnd(false);
		this.isRedsTurn = true;
	}
	
	public void play() {
		initializeBoard();
		if (isRedsTurn) {
			
		}
		sw.layout(bs);
		
	}
	
	public void initializeBoard() {
		bs.setPiece(0, 0, new GameDice(DiceColour.BLUE, DiceType.FIVE, new Point(0, 0)));
		bs.setPiece(1, 0, new GameDice(DiceColour.BLUE, DiceType.ONE, new Point(1, 0)));
		bs.setPiece(2, 0, new GameDice(DiceColour.BLUE, DiceType.TWO, new Point(2, 0)));
		bs.setPiece(3, 0, new GameDice(DiceColour.BLUE, DiceType.SIX, new Point(3, 0)));
		bs.setPiece(4, 0, new GameDice(DiceColour.BLUE, DiceType.KEY, new Point(4, 0)));
		bs.setPiece(5, 0, new GameDice(DiceColour.BLUE, DiceType.SIX, new Point(5, 0)));
		bs.setPiece(6, 0, new GameDice(DiceColour.BLUE, DiceType.TWO, new Point(6, 0)));
		bs.setPiece(7, 0, new GameDice(DiceColour.BLUE, DiceType.ONE, new Point(7, 0)));
		bs.setPiece(8, 0, new GameDice(DiceColour.BLUE, DiceType.FIVE, new Point(8, 0)));
		bs.setPiece(0, 7, new GameDice(DiceColour.RED, DiceType.FIVE, new Point(0, 7)));
		bs.setPiece(1, 7, new GameDice(DiceColour.RED, DiceType.ONE, new Point(1, 7)));
		bs.setPiece(2, 7, new GameDice(DiceColour.RED, DiceType.TWO, new Point(2, 7)));
		bs.setPiece(3, 7, new GameDice(DiceColour.RED, DiceType.SIX, new Point(3, 7)));
		bs.setPiece(4, 7, new GameDice(DiceColour.RED, DiceType.KEY, new Point(4, 7)));
		bs.setPiece(5, 7, new GameDice(DiceColour.RED, DiceType.SIX, new Point(5, 7)));
		bs.setPiece(6, 7, new GameDice(DiceColour.RED, DiceType.TWO, new Point(6, 7)));
		bs.setPiece(7, 7, new GameDice(DiceColour.RED, DiceType.ONE, new Point(7, 7)));
		bs.setPiece(8, 7, new GameDice(DiceColour.RED, DiceType.FIVE, new Point(8, 7)));
		for (int i=1; i<7; i++) {
			for (int j=0; j<9; j++) {
				bs.setPiece(j, i, new GameDice(DiceColour.NULL, DiceType.NULL, new Point(j, i)));
			}
		}
	}

	public void setGf(GameReferee gf) {
		this.gf = gf;
	}

	public GameReferee getGf() {
		return gf;
	}

	public void setEnd(boolean end) {
		this.end = end;
	}

	public boolean isEnd() {
		return end;
	}

	public void setRedsTurn(boolean isRedsTurn) {
		this.isRedsTurn = isRedsTurn;
	}

	public boolean isRedsTurn() {
		return isRedsTurn;
	}
	
}
